const unirest = require("unirest");
const config = require("../config");
const serverUrl = config.serverUrl;

const getServicePageData = function (serviceId) {
    return new Promise(function (resolve, reject) {
        let data = {
            "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写",
            "title2": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写",
            "price": "1000.00",
            "serviceClass": "web",            
            "serviceSliderPhotos": [
                {
                    "id": 1,
                    "url": "/img/serviceSlider/03.png"
                },
                {
                    "id": 2,
                    "url": "/img/serviceSlider/02.jpg"
                },
                {
                    "id": 3,
                    "url": "/img/serviceSlider/01.jpg"
                }
            ],
            "serviceContent": [
                {
                    "id": 1,
                    "url": "/img/serviceContent/01.png"
                },
                {
                    "id": 2,
                    "url": "/img/serviceContent/02.png"
                },
                {
                    "id": 3,
                    "url": "/img/serviceContent/03.png"
                },
                {
                    "id": 4,
                    "url": "/img/serviceContent/04.png"
                },
                {
                    "id": 5,
                    "url": "/img/serviceContent/05.png"
                },
                {
                    "id": 6,
                    "url": "/img/serviceContent/06.png"
                },
                {
                    "id": 7,
                    "url": "/img/serviceContent/07.png"
                },
            ]
        }

        setTimeout(function () {
            resolve(data);
        }, 50);
    });
};


const getServiceData = function (serviceId) {
    return new Promise(function (resolve, reject) {
        let data = {
            "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写",
            "title2": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写",
            "serviceClass": "web",            
            "price": "1000.00",
        }

        setTimeout(function () {
            resolve(data);
        }, 50);
    });
};

const getHotService = function () {
    return new Promise(function (resolve, reject) {
        let data = {
            "hotServices": [
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/08.webp",
                    "price": "￥100",
                    "serviceClass": "web",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },

                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/02.webp",
                    "price": "￥100",
                    "serviceClass": "text",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/07.webp",
                    "price": "￥100",
                    "serviceClass": "media",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/03.webp",
                    "price": "￥100",
                    "serviceClass": "web",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/04.webp",
                    "price": "￥100",
                    "serviceClass": "text",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/05.webp",
                    "price": "￥100",
                    "serviceClass": "web",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/06.webp",
                    "price": "￥100",
                    "serviceClass": "media",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/01.webp",
                    "price": "￥100",
                    "serviceClass": "media",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
            ],
        }

        setTimeout(function () {
            data.hotServices.forEach(element => {
                element.url = "/studio/" + element.studioId + "/service/" + element.serviceId
            });
            resolve(data);
        }, 50);
    })
};

const getServiceByClass = function (serviceClass) {
    return new Promise(function (resolve, reject) {
        let data = {
            "services": [
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/08.webp",
                    "price": "￥100",
                    "serviceClass": "web",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },

                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/02.webp",
                    "price": "￥100",
                    "serviceClass": "text",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/07.webp",
                    "price": "￥100",
                    "serviceClass": "media",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/03.webp",
                    "price": "￥100",
                    "serviceClass": "web",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/04.webp",
                    "price": "￥100",
                    "serviceClass": "text",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/05.webp",
                    "price": "￥100",
                    "serviceClass": "web",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/06.webp",
                    "price": "￥100",
                    "serviceClass": "media",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
                {
                    "serviceId": "23443511",
                    "studioId": "123",
                    "preview": "/img/serviceLogo/01.webp",
                    "price": "￥100",
                    "serviceClass": "media",
                    "title": "网站建设 网站开发 H5网页编写 微信小程序 网站开发 H5网页编写"
                },
            ],
        }

        setTimeout(function () {
            data.services.forEach(element => {
                element.url = "/studio/" + element.studioId + "/service/" + element.serviceId
            });
            resolve(data);
        }, 50);
    });    
};

module.exports = {
    "getServicePageData": getServicePageData,
    "getHotService": getHotService,
    "getServiceByClass": getServiceByClass

}
